package com.shop2cn.iapi.pretrade.testcase;

import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.experimental.categories.Category;

import com.shop2cn.iapi.pretrade.paremeter.OnFinishReq;
import com.shop2cn.iapi.pretrade.service.OnFinishCall;
import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.TestCase;
import com.ymt.utils.annotation.TestSuite;
import com.ymt.utils.tag.P1;
import com.ymttest.database.sharding.db.ext.model.FinishActivityPo;
import com.ymttest.database.sharding.db.sqlwapper.OrderWapper;
import com.ymttest.utils.TestDataManager;

/**
 * 自动确认收货提醒通知FreeMaker Template自动生成代码
 */
@TestSuite
public class Ts_OnFinish {

	private static OnFinishReq onFinishReq;
	private static OnFinishCall onFinishCall;

	@BeforeClass
	public static void setUp() {
		Logger.createResultFile("活动结束通知");
	}

	@Before
	public void caseUp() {
		onFinishReq = new OnFinishReq();
		onFinishCall = new OnFinishCall();
	}

	@AfterClass
	public static void tearDown() {
		Logger.generateResult(onFinishCall.getOpurl());
	}

	@After
	public void caseDown() {
		Logger.end();
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_OnFinish_001() {
		Logger.start(true, "活动结束通知");
		try {

			onFinishReq.setActivityId(Long.valueOf("90") + TestDataManager.getRandomIntNum(9));

			// 发送请求
			onFinishCall.setData(onFinishReq);
			onFinishCall.callService();
			Logger.verifyEquals("ok", onFinishCall.getReturnData(),
					"验证接口返回");
			
			OrderWapper wapper = new OrderWapper();
			
			FinishActivityPo finishActivityPo = wapper.selectFinishActivityByIdActivityId(onFinishReq.getActivityId());
			
			Logger.verifyEquals(onFinishReq.getActivityId(), finishActivityPo.getActivityId(), "验证ActivityId");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
}
